package com.chencong.online.function;

import com.chencong.online.bean.LoginEventBean;
import org.apache.flink.api.common.functions.MapFunction;

/**
 * @program: user-behavior-analysis-online
 * @ClassName LoginEventMapFunc
 * @description:将数据格式化为登陆事件数据
 * @author: chencong
 * @create: 2021-12-31 10:39
 **/
public class LoginEventMapFunc implements MapFunction<String, LoginEventBean> {
    @Override
    public LoginEventBean map(String value) throws Exception {
        String[] split = value.split(",");
        String userId = split[0];
        String ip = split[1];
        String loginState = split[2];
        String timestamp = split[3];

        return new LoginEventBean(
                Long.valueOf(userId),
                ip,
                loginState,
                Long.valueOf(timestamp)
        );
    }
}
